package com.yz.design.strategyDesign;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 多例 策略模式 + 高内聚
 */
@Component
public class Main {
    @Autowired
    private ObjectFactory<StrategyCenter> objectFactory;

    public void requst() throws Exception {
        //spring 自带工厂依赖获取实例 每个实例都是重新生成（解决并发数据一致性）
        StrategyCenter strategyCenter = objectFactory.getObject();
        strategyCenter.init(RequestTypeEnum.JOB_REQUEST);
        strategyCenter.request(strategyCenter);
    }

    public static void main(String[] args) {
//        requst();
    }
}

